package org.jfonia.connect5.numerical;

import org.jfonia.connect5.basics.MutableValueNode;
import org.jfonia.connect5.basics.ValueNode;
import org.jfonia.connect5.relations.ABCRelation;

/**
 * a * b = c
 * Updates c if a or b changed, updates b if c changed
 *
 * Be careful with quotient (rounded down to int)
 *
 * @author wijnand.schepens@hogent.be
 */
public class IntMultiplicationRelation extends ABCRelation<Integer, Integer, Integer>
{
	public IntMultiplicationRelation(ValueNode<Integer> a, MutableValueNode<Integer> b, MutableValueNode<Integer> c)
	{
		super(a, b, c);
	}

	public void updateB()
	{
		b.setValue(c.getValue() / a.getValue(), this);
	}

	public void updateC()
	{
		c.setValue(a.getValue() * b.getValue(), this);
	}
}
